package com.fb;

import java.io.File;

public class CheckFilesAttr extends Thread {
    FileBrowserPage fbp;
    File[] willshow;
    int[] willshowSorted;
    CheckFilesAttr(FileBrowserPage fbp){
        this.fbp=fbp;
    }

    @Override
    public void start() {
        fbp.cfa=this;
        willshow=fbp.willshow;
        willshowSorted=fbp.willshowSorted;
        super.start();
    }
    @Override
    public void run() {
        super.run();
        int[] attrs=fbp.willshowAttr;
        DirectoryListView dlv=fbp.dlv;
        if(willshowSorted==null){
            int ds=fbp.willshowLen;
            int count=(dlv.getHeight()-dlv.startY+dlv.itemHeight-1)/dlv.itemHeight;
            int end=Math.min(ds,dlv.position+count);
            for(int i=dlv.position;i<end;i++){
                File f=willshow[i];
                int attr=attrs[i];
                if(f.exists()){
                    attr|=0x10000000;
                }else{
                    attr&=0x01111111;
                }
                if(interrupted())break;
                attrs[i]=attr;
            }
        }
        fbp.cfa=null;
    }
}
